﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta name="qrichtext" content="1" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
</head>
<body style="font-family:'Tahoma'; font-size:10pt; font-weight:400; font-style:normal;">
<p align="center" style="margin:0px;"><span style="font-family:'Consolas'; font-size:18pt; font-weight:600;">LocustPerfMeter使用说明 </span></p>
<p align="right" style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-weight:600;">By：授客 QQ：1033553122</span></p>
<p align="right" style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:9pt; font-weight:600;"> </span><span style="font-family:'Consolas';"> </span></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:16pt; font-weight:600;">实践环境</span></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#000000; background-color:#ffffff;">win10</span></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#333333;">locustPlus</span></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#000000; background-color:#ffffff;">Python 3.6.5</span></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#000000; background-color:#ffffff;">zope.interface 5.1.2 (LocustPlus依赖包)</span></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#000000; background-color:#ffffff;">zope.event (LocustPlus依赖包)</span></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#000000; background-color:#ffffff;">jmespath 0.10.0</span></p>
<p style="-qt-paragraph-type:empty; margin:18px 0px 12px 0px;"><br /></p>
<p style="margin:18px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:16pt; font-weight:600;">安装LocustPlus</span></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; color:#333333;">安装完成后，运行locust(程序所在目录：python_home\Scripts\locust.exe），如下，如果可以正常运行不报错，说明安装成功，</span></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; color:#333333;">D:\Program Files\python36\Scripts&gt;locust -V</span></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; color:#333333;">locust 1.3.0</span></p>
<p style="-qt-paragraph-type:empty; margin:0px; font-family:'Consolas'; color:#333333;"><br /></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; color:#333333;">实践过程中，运行locust发现如下错误：</span></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; color:#ff0000;">    from zope.interface import Interface</span></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; color:#ff0000;">ModuleNotFoundError: No module named 'zope.interface'</span></p>
<p style="-qt-paragraph-type:empty; margin:0px;"><br /></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; color:#333333;">解决方法：找到zope类库(locust安装所需依赖包)所在目录位置(python_home\Lib\site-packages\zope)，在该目录下，添加一个空的__init__.py文件即可</span></p>
<p style="-qt-paragraph-type:empty; margin:0px; font-family:'Consolas'; color:#333333;"><br /></p>
<p style="margin:0px;"><span style="font-family:'Consolas'; font-size:18pt; font-weight:600;">安装jmespath</span></p>
<p style="-qt-paragraph-type:empty; margin:0px; font-family:'Consolas'; color:#333333;"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:16pt; font-weight:600;">使用</span><span style="font-family:'Consolas'; font-size:18pt; font-weight:600;">LocustPerfMeter</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:15pt; font-weight:600; color:#333333;">config/config.py配置</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Consolas'; color:#333333;"><br /></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">log_level = </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">'DEBUG'</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 日志级别（正式压测时建议配置为INFO，调试时配置为DEBUG）</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">web_ui_host = </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;127.0.0.1&quot;</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># web UI访问地址</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">web_ui_port = </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">8089</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># web UI访问端口</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">master_bind_host = </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">'*'</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># master socket服务地址，用于和slave，controller通信</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">master_bind_port = </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5557</span><span style="font-family:'Courier'; font-size:9pt;">  </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># master socket服务端口，用于和slave，controller通信</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">slave_bind_host = </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">'127.0.0.1'</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 压测机 socket服务地址，用于和master通信</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Consolas'; color:#333333;"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:15pt; font-weight:600; color:#333333;">data/参数文件配置</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#333333;">根据需要添加参数文件</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; color:#333333;">样例：argfile.txt</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Courier'; font-size:9pt; color:#333333;">username,password</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Courier'; font-size:9pt; color:#333333;">a01389,123456</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Courier'; font-size:9pt; color:#333333;">A02848,123456</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Courier'; font-size:9pt; color:#333333;">A02287,123456</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Courier'; font-size:9pt; color:#333333;">A02790,123456</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Courier'; font-size:9pt; color:#333333;">A02778,123456</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Courier'; font-size:9pt; color:#333333;"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:15pt; font-weight:600; color:#333333;">scenarios/scenario_config.py配置</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Consolas'; color:#333333;"><br /></p>
<p style="margin:12px 0px 12px 0px;">场景配置</p>
<p style="margin:12px 0px 12px 0px;"><img src="" /></p>
<p style="margin:12px 0px 12px 0px;">说明：如图，场景配置文件支持嵌套，支持中文(不建议)</p>
<p style="margin:12px 0px 12px 0px;">例子：</p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Courier'; font-size:9pt;">scenario_config = { </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#scenario_config 名称固定。不可更改</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;id&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">1</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#场景id </span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;压测场景名称&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;target_user_count&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">20</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#分配的总压测用户数 # 调试时建议配置成1</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;spawn_rate&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 每秒启动用户数（仅用于控制启动用户的速率</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;initial_user_num&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 初始用户数,要求大于0，且为整数，如果配置为0，后者值不为真、或者未配置该选项，则默认取add的值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">    # 注意 如果add配置项未配置、或者配置值为不为真，则自动忽略 initial_user_num，add， interval配置项的值，即梯度加压不起作用</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;add&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5</span><span style="font-family:'Courier'; font-size:9pt;">,  </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 启动压测试时，启动Y个用户，然后add Y every interval seconds 即刚开始时启动 </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">initial_user_num </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">个用户，然后每 interval 秒 增加 Y 个用户，直到达到 target_user_count</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;interval&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">30</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 单位 秒 # 如果启动用户耗时大于该场景间隔配置，则不等待，继续启动用户</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;hold_load_time&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 每台slave压测机维持负载运行时间， 单位 秒(不包括用户启动耗时和结束耗时),要求大于0</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;iteration_num_each_user&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">1</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 每个用户迭代运行次数(每执行完一条链路算一次迭代) 如果该配置项的值大于0，则每个用户运行该配置项指定次数，并且忽略hold_load_time配置，否则自动忽略该配置项；</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;stop_rate&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#每秒停止用户数</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;host&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;http://127.0.0.1:8001&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#接口地址不能为空， 且必须填写正确</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#  如果同时提供了“ iteration_wait_time”，“ iteration_min_wait” 及“ iteration_max_wait”， 则优先判断iteration_wait_time</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#  iteration_min_wait和iteration_max_wait 必须配合使用， 随机生成等待时间【 iteration_min_wait,iteration_max_wait)， 且两者都不能为空</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;iteration_min_wait&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#每个用户每运行完一轮迭代(执行完所选链路的chain部分)， 开始下一轮迭代前的最小等待时间</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;iteration_max_wait&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#每个用户每运行完一轮迭代(执行完所选链路的chain部分)， 开始下一轮迭代前的最大等待时间</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;iteration_wait_time&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">0</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#每个用户每运行完一轮迭代(执行完所选链路的chain部分)， 开始下一轮迭代前的固定等待时间</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">    # iteration_mode 迭代模式 1-链路串行(每次迭代执行所有链路) 2-链路权重(每次迭代仅执行1条链路[按链路权重选取链路]) 3链路随机(每次迭代仅执行一条链路[按链路权重随机选取])</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;iteration_mode&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">2</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#  可选配置，默认为 2 如果配置为1，自动忽略权重配置</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;scenario&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [{</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;id&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">1</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#链路id 要求唯一</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;链路1&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;weight&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 链路权重 #必填配置</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#####################关于weight配置项的更多说明##############################</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#本样例中，链路权重和为8，链路1占比为5/8，假设运行8次：</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 如果迭代模式为“链路权重”，假设运行8次，该链路1会优先运行有3次，然后链路1和链路2之间按顺序来回切换运行</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 如果迭代模式为“链路随机”，那么链路1被运行的概率为5/8，链路2被运行概率为3/8，注意，这个概率可能存在一定偏差</span></p>
<p style="-qt-paragraph-type:empty; margin:0px; font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"><br /></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 针对每个参与压测用户，此处teardown为可选配置，不参与中间过程(chain部分)的循环，仅在用户退出前最后执行一次</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># &quot;teardown&quot;:[{</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#     &quot;action&quot;: &quot;teardown&quot;,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#     &quot;name&quot;: &quot;数据清理&quot;,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#     &quot;method&quot;: &quot;POST&quot;,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#     &quot;path&quot;: &quot;/api/v1/order/data_clear&quot;,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># }],</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;chain&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [{</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;exec_once_only_controller&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;仅运行一次控制器&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;id&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">5</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#该步骤动作函数的唯一标识（场景链路内唯一，不同链路可以重复）</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;children&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [{</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        # 读取文件需要注意的地方，压测过程中，如果先减少用户数，再增加用户数，新增用户读取文件时，等价于在没有减少用户数的基础上，读取文件</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;read_csv_file_data&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;帐号密码参数配置&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;fileName&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;./data/argfile.txt&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 参数文件配置，参数之间用delimiter指定分隔符隔开</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        ######################## 关于fileName的更多说明 ###############################</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        # 如果fileName为字符串，则表示所有压测节点共享同一个参数文件</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        # 如果fileName为列表，形如['</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">./data/argfile.txt</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">', '</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">./data/argfile.txt2</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">', '</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">./data/argfile3.txt</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">'],则每个压测节点，按顺序取各读取一个参数文件，如果文件数</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        # 小于压测节点数，不够分配给所有压测结点，那么未分配的压测结点，默认共享最后一个参数文件</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        #</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;fileEncoding&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;utf-8&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;variableNames&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;username,password&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#要求变量名称链路内唯一（ 不同链路中定义的变量可以重复）</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;ignoreFirstLine&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">True</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#是否忽略第一行 True 是 False 否</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;delimiter&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;,&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#变量， 变量值之间的分隔符</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;recyleOnEOF&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">True</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#是否循环读取 True 循环读取 False 不循环</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;independently_each_user&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">False</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 是否每个用户独立 True 等价于每个用户从不同的文件副本读取各自所需要的数据， False 等价于每个用户用同一个文件指针、 文件句柄读取同一份文件</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    },</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    {</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;send_request&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;请求登录&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 可选配置 默认为None</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;method&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;POST&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;path&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;/api/v1/login&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#可以是绝对URL， 形如http: //127.0.0.1:8002/api/v1/login，也可以是相对URL,形如 /api/v1/login</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;body&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: { </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 这里如果不为None\不为空，则json配置项会被忽略， #如果json配置了数据，则这里保持为None</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;account&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${username}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;password&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${password}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;func1&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${__module_plugin_func1('参数1'|| '参数2' || key='key参数')}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;func2&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${__module_plugin_func2('参数1'|| '参数2'|| 99|| key='key参数'|| key2= 'k参数2'|| key3=33|| key4 = 36)}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;func3&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${__module_func1(123)}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;func4&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${__module_func2()}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;func5&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${__module_plugin_func2('参数1'|| '参数2'||${__module_func2()})}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;func6&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${__module_plugin_func2('${username}'|| '${password}')}${__module_func2()}&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 函数参数支持变量</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;func7&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;${__module_plugin_func2(set([1,2,3]))}&quot;</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 函数参数支持python原生函数</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">########### 插件函数使用的更多说明 ###########</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 1、格式：${ __函数名称() }、${ __函数名称( 函数参数 ) }</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># #注意：</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 1） 函数名称以 _ 打头</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 2）${之间不能有空格</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 3) 函数名称和函数的左括号 ( 之间不能有空隔</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#</span><span style="font-family:'Courier'; font-size:9pt;"> </span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 2、函数参数之间使用 || 分隔 形如 ${ __function1( &quot;str_value&quot; || 123456 || 'test' )}</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#</span><span style="font-family:'Courier'; font-size:9pt;">    </span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 3、函数支持嵌套，形如：${ __function1( ${__function2()} )}</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 注意：但是填写时注意别嵌套自身，会死循环</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 4、函数参数支持变量，形如  ${ __function1( ${var_name} )}</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            #</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            # 5、函数参数如果是字符串，需要使用单引号、双引号引用 形如 ${ __function1( &quot;str_value&quot;)} ，${ __function1(key=&quot;arg_value&quot;)}，${ __function1(key=\'arg_value\')}，</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            #</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            # 6、字符串替换规则：待替换的字符串，仅包含一个函数表达式，不含其它字符，则该字符串会被替换为函数返回值，如果还包含其它字符，或者包含多个函数，则该字符串替换函数表达式之前，会先转换函数返回值为字符串，然后替换这些函数表达式为转换后的函数返回值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            # 7、函数参数支持python原生函数 形如  ${ __function1( set([1,2,3]) )}</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            #</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            # 8、关键词参数 关键词左右不用使用单、双引号 错误用法 &quot;key&quot;=123,关键词参数如果是字符串，则需要用单、双引号引用 形如 key='arg_value', key=&quot;arg_valu2&quot;</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            #</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                            # 9、支持自定义函数 参考 LocustPerfMeter\utils\plugin_functions目录下的代码样例</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">############################################</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        },                        </span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">########### 关于 body更多使用说明 ###########</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 1、body用于存放位于请求体的请求参数、请求数据</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 2、如果未配置请求头，并且body为字典类型数据，则默认设置 Content-Type 为 application/json;charset=utf-8</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;params&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">None</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 可选配置，默认为None</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">########### 关于 params 的更多使用说明 ###########</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 1、用于存放位于url的参数（确切的说是url中 ? 号之后的参数）</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 2、支持的数据格式:json、字符串</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 举例：</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 假设发起的请求为 GET http:// 127.0.0.1/api/v1/users?name=shouke&amp;occupation=testing</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 那么params可以设置为如下值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># {&quot;name&quot;: &quot;shouke&quot;, &quot;occupation&quot;:&quot;testing&quot;}  #字典类型（非字符串）</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># name=shouke&amp;occupation=testing      #字符串类型                      </span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;stream&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">False</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 可选配置 默认为False</span></p>
<p style="margin:0px;">        <span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                   ########## 关于 stream 的更多使用说明 ###########</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        # 如果设置为true，则不会立即使用响应主体，而是通过访问响应的stream属性来使用响应主体对象。另外，将stream设置为True的副作用是，下载响应内容的时间不会计入由Locust报告的请求时间(If set to true the response body will not be consumed immediately</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        # and can instead be consumed by accessing the stream attribute on the Response object.</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        # Another side effect of setting stream to True is that the time for downloading the response content will not be accounted for in the request time that is reported by Locust)</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">                        # 参考上述解释及python sessions.request函数对该参数的说明，个人理解，这里stream参数如果设置为True,表示会立即下载response，否则不会</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"> </span><span style="font-family:'Courier'; font-size:9pt;">                       </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;headers&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: { </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 可选配置 默认为None</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;Content-Type&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;application/json&quot;</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        },</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">########### 关于 headers 的更多使用说明 ###########</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 1、如果headers为None、空等False值、未配置Content-Type，则</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># a) # 如果发起的请求为get请求，且params不为空、None等False值，则默认设置 Content-Type 为 application/x-www-form-urlencoded;charset=utf-8</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># b) 如果发起的请求为post请求，且params不为空、None等False值, 且body为空、None等False值，则默认设置 Content-Type 为 application/x-www-form-urlencoded;charset=utf-8</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># c) 如果body为字典，则默认设置 Content-Type 为 application/json;charset=utf-8</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># d) 其它情况，不对Content-Type请求头做任何配置</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;auth&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">None</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 可选配置 默认为None</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;allow_redirects&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">True</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">可选配置 默认为True</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># children为可选配置</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;children&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [{ </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 如果不配置响应断言，系统会执行默认断言 响应状态码为 200，201，301则算通过</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;assert_response&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;请求响应断言&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;target&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;body&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;rule&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;assert_contain&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#模式要匹配的规则,目前支持 assert_contain 包含  assert_equal 等于</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;patterns&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;赖某人&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;token&quot;</span><span style="font-family:'Courier'; font-size:9pt;">], </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 模式 [模式1，模式2，模式3] </span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;logic&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;or&quot;</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 模式之间的逻辑关系 and 、or  可不配置logic配置项，默认为and</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        }, {</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;extract_by_regexp&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#正则表达式提取器 </span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;正则表达式提取器&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;refName&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;userInfo&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#引用名称 # 不能为空</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;express&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">'username&quot;:&quot;(.+?)&quot;,.+token&quot;:&quot;(.+?)&quot;,'</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#正则表达式</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;target&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;body&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 提取源对象</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;template&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;$1$$2$$0$&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 默认为$0$ $0$-取分组0数据（分组1到分组n按顺序拼接起来的数据） $1$-取分组1数据 $2$-取分组2数据 以此类推,如果给定索引越界</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;matchNo&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">0</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 默认为0，取分组中指定匹配索引的数据 matchNo 0开始，0表示随机，1表示取分组中第一个值 2 取第二个分组的值 以此类推， 如果越界，提取结果为空</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        }, {</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;extract_by_jmespath&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#JSON提取器</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">:</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;jmespath提取器&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;refName&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;token&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#引用名称 # 不能为空</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;express&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">'data.token'</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#jmespath表达式 参考 https://jmespath.org/tutorial.html</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;target&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;body&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 提取源对象目标域(固定为body)</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                        }]</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    }</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                ]</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">            }, {</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;send_request&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;获取菜单&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;method&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;GET&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;path&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;/api/v1/user/menus&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;stream&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">False</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;headers&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">None</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;auth&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">None</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;allow_redirects&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">True</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;children&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [{</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;assert_response&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;请求响应断言&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;target&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;status&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;rule&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;assert_equal&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                    </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;patterns&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [</span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">200</span><span style="font-family:'Courier'; font-size:9pt;">]</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                }]</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">            }, {</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;exec_counter&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;counter1&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;refName&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;counter1&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#要求计数器引用名称链路内唯一（ 不同链路中定义的计数器引用变量可以重复）</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;value&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">1</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#初始值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;increment&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">2</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#增量步长值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;maximum&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">1000</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#最大值 #未实现</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;numberFormat&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;100000&quot;</span><span style="font-family:'Courier'; font-size:9pt;">, </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">#格式化 #未实现</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">                </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;independently_each_user&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#8b008b;">False</span><span style="font-family:'Courier'; font-size:9pt;"> </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 是否每个用户独立 True 每个用户拥有自己的独立计数器 False 所有用户共享一个计数器</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">            }</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">           </span><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;"># 此处即chain list内部的teaardown会参与迭代执行，即不同于普通action，每轮执行过程中，不管中间运行过程是否报错，如果有配置该action，该action都会被执行</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt; font-style:italic; color:#778899;">           # 需要注意的是：1）teardown action 必须作为chain list的直接元素,顺序不限 2) teardown里面不支持嵌套teardown action</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">           ,{</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">               </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;teardown&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">               </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;数据清理&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">               </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;method&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;POST&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">               </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;path&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;/api/v1/order/data_clear&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">           }</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        ]</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    }, {</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;id&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">2</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;链路2&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;weight&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#4682b4;">3</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;chain&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: [{</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;action&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;send_request&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;name&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;请求订单&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;method&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;GET&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">            </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;path&quot;</span><span style="font-family:'Courier'; font-size:9pt;">: </span><span style="font-family:'Courier'; font-size:9pt; font-weight:600; color:#2e8b57;">&quot;/api/v1/order/1&quot;</span><span style="font-family:'Courier'; font-size:9pt;">,</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">        }]</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">    }]</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">}</span></p>
<p style="-qt-paragraph-type:empty; margin:0px; font-family:'Courier'; font-size:9pt;"><br /></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">说明：</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">1、变量引用方式 ${ 变量名称 }， $和{之间不能有空格</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">2、变量名称支持的格式如下：</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">   varName 获取该变量名为varName的变量值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">   varName.attribute 表示获取变量名为varName的字典变量的attribute属性值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">   varName[N] 表示获取变量名为varName的列表、元组变量值中，索引为的N的元素值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">   支持组合 varName[1].id  varName[1][0].data[0].id</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">   example:</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">   varName.id 获取变量名为varName的字典变量的id属性值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">   varName[1] 获取变量名为varName的列表、元组中索引为1的元素值</span></p>
<p style="margin:0px;"><span style="font-family:'Courier'; font-size:9pt;">3、程序按场景链路顺序执行</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:15pt; font-weight:600; color:#333333;">运行LocustMaster</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">建议优先运行locust_master，然后再运行locust_slave</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">pycharm为例，直接打开脚本，右键运行即可</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Consolas';"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">说明：</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">1、如果locust_master已启动，并且在执行压测，那么后面开启的locust_slave不会自动参与到压测中，总用户数不变，除非执行 调整用户数、重新开始压测</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">2、压测过程中确保master程序不挂掉，挂掉会导致压测统计计数不准确，目前还没解决这个问题，所以建议压测时，中规中矩的来~~</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:15pt; font-weight:600; color:#333333;">运行LocustSlave</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">pycharm为例，直接打开脚本，右键运行即可</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">支持多开，分布式运行</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:15pt; font-weight:600; color:#333333;">运行controller</span></p>
<p style="margin:12px 0px 12px 0px;">pycharm为例，直接打开脚本，右键运行即可</p>
<p style="margin:12px 0px 12px 0px;"><img src="" /></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="margin:12px 0px 12px 0px;">说明：</p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">3-调整启动速率 locust_master如果不是正处于启动用户阶段，重新配置config/scenario_config.py 启动用户速率（spwan_rate），然后重新运行controller，再执行该命令有效</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">4-调整停止速率 locust_master如果不是正处于停止用户阶段，重新配置config/scenario_config.py 停止用户速率（stop_rate），然后重新运行controller，再执行该命令有效</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">8-关闭压测程序 结束locust_master，locust_slave程序</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">9-退出controller 结束controller程序</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Consolas';"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; background-color:#ffff00;">待所有节点都开启，并且保证每个结点开启后，至少运行3秒后(确保slave结点都注册到master)再开始压测，否则可能会导致部分节点不参与执行压测，导致执行次数和执行用户数比配置少：</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; background-color:#ffff00;">slave程序每次开启都是生成一个新的worker id，并给master程序发送心跳消息，master通过心跳判断slave是否存在，默认3秒内，没收到消息，判断该slave程序down了，并移除该结点，收到消息则把该salve结点添加到压测机范围，下次执行压测时同其它结点一起参与压测。</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:15pt; font-weight:600; color:#333333;">步骤action支持件式开发</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">参考components/plugin/example.py </span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Consolas';"><br /></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas'; font-size:16pt; font-weight:600;">参考连接</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">https://docs.locust.io/en/stable/api.html#responsecontextmanager-class</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">https://docs.locust.io/en/stable/use-as-lib.html</span></p>
<p style="margin:12px 0px 12px 0px;"><span style="font-family:'Consolas';">http://www.gevent.org/api/gevent.html#getting-greenlets</span></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px; font-family:'Consolas';"><br /></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
<p style="-qt-paragraph-type:empty; margin:12px 0px 12px 0px;"><br /></p>
</body>
</html>